home *** CD-ROM | disk | FTP | other *** search
- (* Program to take an ASCII file from the TF program and print a nice
- readable phone directory suitable for use in a small loose-leaf
- notebook. Also can be used to print Roladex cards.
-
- Original: 09/23/86 By: J. Eric Slone *)
-
- {$U+,C+}
-
- type bookrec = record
- firstname :string[15];
- lastname :string[30];
- company :string[40];
- address1 :string[40];
- address2 :string[40];
- telephone :string[15];
- exten :string[5];
- remark1 :string[40];
- remark2 :string[40];
- remark3 :string[40];
- end;
- bookfiletype = file of bookrec;
-
- var null, ans, last :char;
- blank, i, ind, numb,
- results, ppage :integer;
- bookfile :bookfiletype;
- entry :bookrec;
-
- (* Uses Turbo Pascal Database Toolkit Quick Sort. *)
-
- {$I SORT.BOX }
-
- (* Convert the ASCII file to a record-type file so that it can be properly
- read in. Sloppy, but it needs to be here. This should be fixed some day
- and added to the read in procedure. *)
-
- procedure addcr;
- type io = record
- fn :string[15];
- ln :string[30];
- co :string[40];
- a1 :string[40];
- a2 :string[40];
- tn :string[15];
- ex :string[5];
- r1 :string[40];
- r2 :string[40];
- r3 :string[40];
- end;
- var infile :text;
- fn, tn :string[15];
- ln :string[30];
- co, a1, a2, r1, r2, r3 :string[40];
- ex :string[5];
- outfile :file of io;
- temp :io;
- begin
- assign (infile, 'book');
- assign (outfile, 'book.prn');
- {$I+}
- reset (infile);
- {$I-}
- if ioresult<>0 then
- begin
- clrscr;
- writeln ('ERROR - BOOK NOT IN CURRENT DIRECTORY');
- halt;
- end;
- {$I+}
- rewrite (outfile);
- {$I-}
- if ioresult<>0 then
- begin
- clrscr;
- writeln ('ERROR - BOOK.PRN CANNOT BE OPENED');
- halt;
- end;
- while not eof (infile) do
- begin
- read (infile, fn);
- read (infile, ln);
- read (infile, co);
- read (infile, a1);
- read (infile, a2);
- read (infile, tn);
- read (infile, ex);
- read (infile, r1);
- read (infile, r2);
- readln (infile, r3);
- temp.fn:=fn;
- temp.ln:=ln;
- temp.co:=co;
- temp.a1:=a1;
- temp.a2:=a2;
- temp.tn:=tn;
- temp.ex:=ex;
- temp.r1:=r1;
- temp.r2:=r2;
- temp.r3:=r3;
- write (outfile, temp);
- end;
- close (infile);
- close (outfile);
- end;
-
- (* Input the data to be sorted and printed. *)
-
- procedure inp;
- var rec :integer;
- begin
- rec:=0;
- repeat
- rec:=rec+1;
- read (bookfile, entry);
- sortrelease (entry);
- until eof (bookfile);
- end;
-
- (* Define the sort order. *)
-
- function less;
- var firsttype :bookrec absolute x;
- secondtype :bookrec absolute y;
- begin
- less:=firsttype.lastname<secondtype.lastname;
- end;
-
- (* Issue a form-feed to the printer. *)
-
- procedure form;
- var k :integer;
- begin
- k:=12;
- writeln (LST, chr(k));
- end;
-
- (* Indent a number of spaces while printing. *)
-
- procedure indent;
- var x :integer;
- begin
- for x:=1 to ind do
- write (LST, null);
- end;
-
- (* Output the data to the printer.
-
- rev 10/14/86 Added page break on new beginning letter in last name *)
-
- procedure outp;
- var i :integer;
- begin
- last:=' ';
- numb:=0;
- repeat
- sortreturn (entry);
- with entry do
- begin
- if lastname[1]<>last then
- begin
- form;
- last:=lastname[1];
- writeln (LST, last, '---------');
- end
- else
- writeln (LST, '----------');
- if keypressed then halt;
- indent;
- writeln (LST, firstname, ' ', lastname);
- if company[1]<>' ' then
- begin
- indent;
- writeln (LST, company);
- end;
- if address1[1]<>' ' then
- begin
- indent;
- writeln (LST, address1);
- end;
- if address2[1]<>' ' then
- begin
- indent;
- writeln (LST, address2);
- end;
- writeln (LST, ' ');
- indent;
- writeln (LST, telephone, ' Ext: ', exten);
- writeln (LST, ' ');
- if remark1[1]<>' ' then
- begin
- indent;
- writeln (LST, remark1);
- end;
- if remark2[1]<>' ' then
- begin
- indent;
- writeln (LST, remark2);
- end;
- if remark3[1]<>' ' then
- begin
- indent;
- writeln (LST, remark3);
- end;
- numb:=numb+1;
- if numb=ppage then
- begin
- numb:=0;
- form;
- end;
- end;
- until sorteos;
- end;
-
- (* The opening screen. Also, set the indent and records-per-page variables.
-
- rev 10/14/86 Stopped form feed with each test pattern
- Fixed spacing *)
-
- procedure opening;
- begin
- clrscr;
- writeln ('PHONE BOOK PRINTING PROGRAM FOR THE TF PHONE DATABASE PROGRAM');
- writeln;
- writeln ('Version 1.21 10/14/86');
- writeln;
- writeln ('Written by: J. Eric Slone');
- writeln (' 2523 Wilson Boulevard #3');
- writeln (' Arlington, VA 22201');
- writeln;
- writeln ('This program is in the public domain.');
- writeln;
- writeln;
- writeln ('DIRECTIONS: Save your phone directory by using F5 from the');
- writeln (' TF program. You should name the ASCII file BOOK. After');
- writeln (' exiting TF, run this program. A sorted record-type file');
- writeln (' named BOOK.PRN will be created containing all records');
- writeln (' sorted by last name. When printing, make sure that your');
- writeln (' printer is in the correct font and lines-per-inch mode.');
- writeln (' You can print the test pattern as many times as needed to');
- writeln (' achieve this setting. The length of the test line represents');
- writeln (' the maximum characters that will be printed on a line by');
- writeln (' this program. ');
- writeln;
- write ('PRESS ANY KEY TO CONTINUE...');
- while not keypressed do
- null:=' ';
- clrscr;
- writeln ('PHONE BOOK PRINTING PROGRAM FOR THE TF PHONE DATABASE PROGRAM');
- writeln;
- writeln;
- writeln ('Version 1.21 10/14/86 J. Eric Slone');
- writeln;
- writeln;
- ind:=4;
- ans:='y';
- while ans in ['y', 'Y'] do
- begin
- gotoxy (1, 15);
- write ('Indent spaces [RETURN=', ind, ']: ');
- readln (ind);
- if (ind<=0) or (ind>10) then ind:=4;
- writeln;
- write ('Print a test pattern? [Y/N] ');
- readln (ans);
- if ans in ['y', 'Y'] then
- begin
- indent;
- writeln (LST, '++++|++++1++++|++++2++++|++++3++++|++++4++++|+');
- end;
- end;
- writeln;
- writeln;
- write ('Number of entries per page [1 5/8" per entry]: ');
- readln (ppage);
- writeln;
- writeln ('PRESS CONTROL-BREAK TO ABORT PRINTING');
- writeln;
- end;
-
- (* The main program. *)
-
- begin
- opening;
- addcr;
- assign (bookfile, 'book.prn');
- {$I+}
- reset (bookfile);
- {$I-}
- if ioresult<>0 then
- begin
- clrscr;
- writeln ('ERROR - BOOK.PRN NOT IN CURRENT DIRECTORY');
- halt;
- end;
- results:=turbosort (sizeof(bookrec));
- if results<>0 then
- begin
- halt;
- writeln;
- writeln;
- writeln ('A SORT ERROR HAS OCCURED');
- end;
- erase (bookfile);
- end.